package test;

import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.itheima.shop.entity.User;
import com.itheima.shop.mapper.UserMapper;

public class UserDemo {
	private final Logger logger = LoggerFactory.getLogger(TestDemo.class);

	UserMapper userMapper;
	ApplicationContext ctx  = null;
	
	@Before
	public void before(){
		logger.info("before");
		ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		userMapper = ctx.getBean(UserMapper.class);
	}
	
	@Test
	public void test001() {
//		userMapper.findById(13);
		User user=userMapper.findByUsername("Jack");
		logger.info(user.toString());
	}
	@Test
	public void test2() {
		User user =new User();
		user.setUsername("name");
		user.setPassword("123456");
		user.setBirthday("2019-06-01");
		user.setCode("1234");
		user.setEmail("name@qq.com");
		user.setSex("女");
		user.setState(0);
		user.setName("name");
		user.setTelephone("123456789123");
		int num=userMapper.insert(user);
		logger.info(num+"");
	}
}
